<?php
namespace Home\Controller;
use Think\Controller;
class UserController extends Controller 
{
    public function register()
    {
    	if(IS_POST)
    	{
    		$model = D('User');
    		if($model->create(I('post.'), 1))
    		{
    			if($id = $model->add())
    			{
    				$this->success('添加成功！', U('Home/Goods/index'));
    				exit;
    			}
    		}
    		$this->error($model->getError());
    	}

		$this->display();
    }


    //用户登录
    public function login(){
        if(IS_POST){
            $userModel = D('user');
            $row=$userModel->login();
            if($row){
                session('uid',$row['uid']);
				if($_COOKIE['cart']){
					$cartModel = D('cart');
					$cartModel->cookietoDB();
				}
				$this->success('登陆成功',U('Home/Goods/index'),3);
            }
            var_dump($_SESSION);
        }
        $this->display();
    }
}